import request from '@/utils/request';

export function getNovelList(params) {
  return request.get('/novel/list', params);
}

export function getNovelDetail(id) {
  return request.get(`/novel/${id}`);
}

export function createNovel(data) {
  return request.post('/novel', data);
}

export function updateNovel(id, data) {
  return request.put(`/novel/${id}`, data);
}

export function deleteNovel(id) {
  return request.delete(`/novel/${id}`);
}

export function getChapterList(params) {
  return request({
    url: '/chapter/list',
    method: 'get',
    params
  });
}

export function getChapterDetail(id) {
  return request({
    url: `/chapter/${id}`,
    method: 'get'
  });
}

export function createChapter(data) {
  return request({
    url: '/chapter',
    method: 'post',
    data
  });
}

export function updateChapter(id, data) {
  return request({
    url: `/chapter/${id}`,
    method: 'put',
    data
  });
}

export function deleteChapter(id) {
  return request({
    url: `/chapter/${id}`,
    method: 'delete'
  });
}

export function batchImportChapters(novelId, data) {
  return request({
    url: `/novel/${novelId}/chapters/batch`,
    method: 'post',
    data
  });
}

export function getCategoryList(params) {
  return request.get('/category/list', params);
}

export function createCategory(data) {
  return request.post('/category', data);
}

export function updateCategory(id, data) {
  return request.put(`/category/${id}`, data);
}

export function deleteCategory(id) {
  return request.delete(`/category/${id}`);
}

export function getAuthorList(params) {
  return request.get('/author/list', params);
}

export function createAuthor(data) {
  return request.post('/author', data);
}

export function updateAuthor(id, data) {
  return request.put(`/author/${id}`, data);
}

export function deleteAuthor(id) {
  return request.delete(`/author/${id}`);
}

// 评论相关
export function getCommentList(params) {
  return request.get('/comment/list', params);
}

export function approveComment(id) {
  return request.post(`/comment/${id}/approve`);
}

export function rejectComment(id) {
  return request.post(`/comment/${id}/reject`);
}

export function deleteComment(id) {
  return request.delete(`/comment/${id}`);
} 